﻿using CampusTrade.Dao;
using CampusTrade.Pojo;
using Furion.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CampusTrade.Service
{
    public class GoodService : ITransient
    {
        private readonly GoodDao goodDao;
        public GoodService(GoodDao goodDao)
        {
            this.goodDao = goodDao;
        }
        /**
         * 获取分类信息
         */
        public List<Classification> getClassifications()
        {
            return goodDao.selectAllClassification();
        }
        /**
         * 发布供需信息
         */
        public long addGood(Good good)
        {
            return goodDao.add(good);
        }
        /**
         * 删除供需信息
         */
        public int deleteGood(long id)
        {
            return goodDao.delete(id);
        }
        /**
         * 更改供需信息状态为status
         */
        public int changeStatus(long goodId, int status)
        {
            Good good = goodDao.select(goodId);
            good.StatusId = status;
            return goodDao.updateStatus(good);
        }
    }
}
